package Testes;

import static org.junit.Assert.*;

import org.junit.Test;

import DAO.AlunoDaoImplArquivo;
import DAO.HistoricoTurmaDaoImplArquivo;
import DAO.NotaDaoImplArquivo;
import Pojo.Aluno;
import Pojo.HistoricoTurma;
import Pojo.Turma;

public class HistoricoTurmaDaoImplArquivoTest {

	@Test
	public void insercaoNaListaDaCerto() throws Exception{
		Aluno aluno = new Aluno(1,"Thiago","09989403643");
		Turma turma = new Turma(1,2012,1,"ctan","08:00-09:40",2,true);
		HistoricoTurma historicoTurma = new HistoricoTurma(2, 10, 8.0, true, aluno,turma);
		assertEquals(true, new HistoricoTurmaDaoImplArquivo().adicionarHistoricoTurma(historicoTurma));
	}
	
	@Test
	public void insercaoNaListaDaErrado() throws Exception{
		Aluno aluno = new Aluno(1,"Thiago","09989403643");
		Turma turma = new Turma(1, 2013, 1, "csa", "08:00-09:40", 90,false);
		HistoricoTurma historicoTurma = new HistoricoTurma(1, 10, 8, true,aluno,turma);
		assertEquals(false, new HistoricoTurmaDaoImplArquivo().adicionarHistoricoTurma(historicoTurma));
	}
	
	@Test
	public void remocaoNaListaDaCerto() throws Exception{
		Aluno aluno = new Aluno(1,"Thiago","09989403643");
		Turma turma = new Turma(10, 2013, 1, "csa", "08:00-09:40", 90,false);
		HistoricoTurma historicoTurma = new HistoricoTurma(1, 10, 8, true,aluno,turma);
		assertEquals(true, new HistoricoTurmaDaoImplArquivo().removerHistoricoTurma(historicoTurma));
	}
	
	@Test
	public void verificarAlunoCadastradoTurmaDaCerto() throws Exception{
		HistoricoTurmaDaoImplArquivo historicoDao = new HistoricoTurmaDaoImplArquivo();
		assertNotSame(-1, historicoDao.verificarAlunoCadastradoTurma(1, 1));
	}
	
	@Test
	public void verificarAlunoCadastradoTurmaDaErrado() throws Exception{
		HistoricoTurmaDaoImplArquivo historicoDao = new HistoricoTurmaDaoImplArquivo();
		assertSame(-1, historicoDao.verificarAlunoCadastradoTurma(1, 1098));
	}

	@Test
	public void pesquisarAlunosPorTurmaDaCerto() throws Exception{
		HistoricoTurmaDaoImplArquivo historicoDao = new HistoricoTurmaDaoImplArquivo();
		Turma turma = new Turma(1,2012,1,"ctan","08:00-09:40",2,true);
		assertNotSame(0,historicoDao.pesquisarAlunosPorTurma(turma).size());
	}
	
	@Test
	public void pesquisarAlunosPorTurmaDaErrado() throws Exception{
		HistoricoTurmaDaoImplArquivo historicoDao = new HistoricoTurmaDaoImplArquivo();
		Turma turma = new Turma(100,2012,1,"ctan","08:00-09:40",2,true);
		assertSame(0,historicoDao.pesquisarAlunosPorTurma(turma).size());
	}
	
	@Test
	public void procurarPorAlunoETurmaDaCerto() throws Exception{
		HistoricoTurmaDaoImplArquivo historicoDao = new HistoricoTurmaDaoImplArquivo();
		Turma turma = new Turma(1,2012,1,"ctan","08:00-09:40",2,true);
		Aluno aluno = new Aluno(1,"Thiago","09989403643");
		assertNotNull(historicoDao.procurarPorAlunoETurma(aluno,turma));
	}
	
	@Test
	public void procurarPorAlunoETurmaDaErrado() throws Exception{
		HistoricoTurmaDaoImplArquivo historicoDao = new HistoricoTurmaDaoImplArquivo();
		Turma turma = new Turma(1,2012,1,"ctan","08:00-09:40",2,true);
		Aluno aluno = new Aluno(10090,"Thiago","09989403643");
		assertNull(historicoDao.procurarPorAlunoETurma(aluno,turma));
	}
	
	@Test
	public void procurarPorTurmaDaCerto() throws Exception{
		HistoricoTurmaDaoImplArquivo historicoDao = new HistoricoTurmaDaoImplArquivo();
		Turma turma = new Turma(1,2012,1,"ctan","08:00-09:40",2,true);
		assertNotSame(0,historicoDao.procurarPorTurma(turma).size());
	}
	
	@Test
	public void procurarPorTurmaDaErrado() throws Exception{
		HistoricoTurmaDaoImplArquivo historicoDao = new HistoricoTurmaDaoImplArquivo();
		Turma turma = new Turma(1,2012,1,"ctan","08:00-09:40",2,true);
		assertSame(0,historicoDao.procurarPorTurma(turma).size());
	}
}
